#include <iostream>
#include <unordered_map>
using namespace std;

string s;
int mp[26];
int kind;

int main()
{
    cin >> s;
    int n = s.size();
    int ret = n;
    for(int left = 0,right = 0;right < n;right++)
    {
        if(mp[s[right] - 'a']++ == 0)
        {
            kind++;
        }
        while(kind == 26)
        {
            ret = min(ret,right - left + 1);
            if(mp[s[left] - 'a']-- == 1)
            {
                kind--;
            }
            left++;
        }
    }
    cout << ret << endl;


    return 0;
}